<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<body>
    <script>
        function factorSum(n) {
            var s = 0
            for (var i = 1; i < n; i ++) {
                if (n % i == 0) {
                    s += i
                }
            }
            return s
        }

        for (var i = 1; i <= 2000; i ++) {
            var a = factorSum(i)
            var b = factorSum(a)
            if (b == i && i != a) {
                console.log(i,a)
            }
        }
    </script>
</body>
</html>